﻿Imports System.Data.SqlClient




Public Class UsuariosDAO
    Inherits Datos
    Public _UsuarioDAO
    Public _PasswordDAO
    Public Coll As New List(Of Usuarios)
    Public reader As SqlDataReader
    Dim Str As String = "server=127.0.0.1\SQLEXPRESS;uid=java;pwd=java;database=BD2;"

    Sub New()
        Me._UsuarioDAO = _UsuarioDAO
        Me._PasswordDAO = _PasswordDAO

    End Sub

    Public Property Usuario() As String
        Get
            Return Me._UsuarioDAO
        End Get
        Set(ByVal value As String)
            Me._UsuarioDAO = value
        End Set
    End Property



    Public Property Password() As String
        Get
            Return Me._PasswordDAO
        End Get
        Set(ByVal value As String)
            Me._PasswordDAO = value
        End Set
    End Property

    Function GetUsuarioporusuario()
        Dim result As New ArrayList()
        Dim Conn As New SqlConnection(Str)
        Conn.Open()
        Dim Cmd As New SqlCommand("SELECT TOP 10 * FROM USUARIOS", Conn)
        Dim reader = Cmd.ExecuteReader()
        While reader.Read
            Dim User As New Usuarios
            User.Nombre = reader(1).ToString
            User.Password = reader(2).ToString
            User.Perfil = reader(3).ToString
            Coll.Add(User)
        End While
        Conn.Close()
        Return Coll
    End Function

    Function GetUsuario(ByRef Usuario, ByRef Password)
        Dim Conn As New SqlConnection(Str)
        Conn.Open()
        Dim Cmd As New SqlCommand("SELECT * FROM USUARIOS WHERE USUARIO='" + Usuario + "' and PASSWORD='" + Password + "'", Conn)
        Dim reader = Cmd.ExecuteReader
        Return reader
        Conn.Close()
    End Function

End Class
